package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.NursingLevel;
import com.zzyl.vo.NursingLevelVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface NursingLevelMapper {
    /**
     * 查询全部
     * @return
     */
    @Select("SELECT nursing_level.*, nursing_plan.plan_name, sys_role.role_name creator\n" +
            "FROM nursing_level\n" +
            "         LEFT JOIN nursing_plan ON nursing_level.lplan_id = nursing_plan.id\n" +
            "         LEFT JOIN sys_role ON nursing_level.create_by = sys_role.id;")
    List<NursingLevelVo> listAll();

    /**
     * 更新
     * @param nursingLevelVo
     */
    void update(NursingLevelVo nursingLevelVo);

    /**
     * 新增
     * @param nursingLevel
     */
    @Insert("INSERT INTO nursing_level(name, lplan_id, fee, status, description, create_time, create_by, update_by, remark, update_time) \n" +
            "VALUES (#{name}, #{lplanId}, #{fee}, #{status}, #{description}, #{createTime}, #{createBy}, #{updateBy}, #{remark}, #{updateTime})")
    void insertLevel(NursingLevel nursingLevel);

    /**
     * 条件分页查询
     */
    Page<NursingLevelVo> selectByPage(@Param("name") String name, @Param("status") Integer status);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select nursing_level.*,nursing_plan.plan_name planName from nursing_level left join nursing_plan on nursing_level.lplan_id = nursing_plan.id where nursing_level.id = #{id}")
    NursingLevelVo selectById(Integer id);

    /**
     * 根据id查询删除
     */
    @Delete("delete from nursing_level where id = #{id}")
    void delete(Integer id);

    /**
     * 设置禁用启用
     * @param id
     * @param status
     */
    @Update("update nursing_level set status = #{status} where id = #{id}")
    void setStatus(Integer id,Integer status);
}
